package com.example.smartcity.ui.selfCenter;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.bumptech.glide.load.engine.Resource;
import com.example.smartcity.R;
import com.example.smartcity.ui.selfCenter.Fragment.NoPayFragment;
import com.example.smartcity.ui.selfCenter.Fragment.PayFragment;

public class MyOrder extends AppCompatActivity implements View.OnClickListener {

    private TextView btnPayTrue;
    private TextView btnPayFalse;
    private FrameLayout frameLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
        btnPayTrue = (TextView) findViewById(R.id.btn_PayTrue);
        btnPayFalse = (TextView) findViewById(R.id.btn_PayFalse);
        frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
        initView();
    }
    public void setBack(View view){
        this.finish();
    }
    public void initView(){
        replaceFragment(new NoPayFragment());
        btnPayFalse.setOnClickListener(this);
        btnPayTrue.setOnClickListener(this);
    }
    public void replaceFragment(Fragment fragment){
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.frameLayout,fragment);
        transaction.commit();
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_PayFalse:
                btnPayFalse.setBackgroundColor(Color.parseColor("#007AFC"));
                btnPayFalse.setTextColor(Color.parseColor("#FFFFFF"));
                btnPayTrue.setBackgroundColor(Color.parseColor("#FFFFFF"));
                btnPayTrue.setTextColor(Color.parseColor("#007AFC"));
                replaceFragment(new NoPayFragment());
                break;
            case R.id.btn_PayTrue:
                btnPayTrue.setBackgroundColor(Color.parseColor("#007AFC"));
                btnPayTrue.setTextColor(Color.parseColor("#FFFFFF"));
                btnPayFalse.setBackgroundColor(Color.parseColor("#FFFFFF"));
                btnPayFalse.setTextColor(Color.parseColor("#007AFC"));
                replaceFragment(new PayFragment());
                break;
        }
    }
}